package qlsl.androiddesign.view.subview.activityview;

import com.qlsl.androiddesign.kuaiwa.R;

import android.content.Intent;
import android.view.View;
import android.widget.BaseAdapter;
import qlsl.androiddesign.activity.subactivity.MachineActivity;
import qlsl.androiddesign.adapter.subadapter.MachineAdapter;
import qlsl.androiddesign.entity.otherentity.Machine;
import qlsl.androiddesign.http.service.subservice.CarService;
import qlsl.androiddesign.view.subview.activityview.peoplecenterbase.PeopleCenterBaseView;

/**
 * 机型列表页<br/>
 * 需要传入的键：<br/>
 * 传入的值类型： <br/>
 * 传入的值含义：<br/>
 * 是否必传 ：
 */
public class MachineView extends PeopleCenterBaseView<Machine, MachineActivity> {

	public MachineView(MachineActivity activity) {
		super(activity);
	}

	protected void initView(View view) {
		super.initView(view);
		setTitle("机型");
	}

	protected void initData() {
		super.initData();
		CarService.queryMachineList(this, activity);
	}

	protected void initListener() {
		super.initListener();
	}

	public void onClick(View view) {
		switch (view.getId()) {
		case R.id.list_item:
			doClickListItem(view);
			break;
		}
	}

	private void doClickListItem(View view) {
		int position = refreshView.getRefreshableView().getPositionForView(view);
		Machine item = (Machine) refreshView.getAdapter().getItem(position);
		Intent intent = new Intent();
		intent.putExtra("name", item.getName());
		activity.setResult(0, intent);
		activity.finish();
	}

	public BaseAdapter getAdapter() {
		return new MachineAdapter(activity, list);
	}

}
